/*****************************************************************************
Copyright 2006 Kervin L. Pierre
    EMAIL: otlkcon@adevsoft.com

This file is part of Otlkcon.

Otlkcon is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

Otlkcon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Lesser GNU General Public License for more details.

You should have received a copy of the Lesser GNU General Public License
along with Otlkcon; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*******************************************************************************/

#pragma once
#include "StdAfx.h"
#include "O_IXPLogon.h"
#include "O_IMSProvider.h"

#ifdef OTLKCON_XP_CALDAV
#include <protocols/caldav/caldav.h>
#endif

class O_IXPProvider : public IXPProvider
{
public:
	MAPI_IUNKNOWN_METHODS(IMPL);
    MAPI_IXPPROVIDER_METHODS(IMPL);

    O_IXPProvider(void);
    ~O_IXPProvider(void);

    HRESULT Create(otlkcon_memory *m);
    HRESULT Destroy();

    HRESULT ProcessEvent( otlkcon_event_struct *ev );
    HRESULT OnGetId( otlkcon_event_struct *ev );

    HRESULT GetStore(LPMAPISUP lpMAPISup, ULONG ulUIParam,
                    O_IXPPMsgStore **msgstore, ULONG ulFlags );
    HRESULT RefreshStores();

    HINSTANCE hInstance;

    O_IMSProvider *lpMSProvider;

    // FIXME: This should probably be a map.
    vector<O_IMSPMsgStore *> MSPMsgStores;
    vector<O_IABPMsgStore *> ABPMsgStores;

private:    
    // Our main, private message store.
    O_IXPPMsgStore *lpMsgStore;

    ULONG cRef;
	CRITICAL_SECTION cs;
    otlkcon_memory *memObj;
    BOOL xpEnabled;

    O_ENTRYID *entryID;

    // FIXME: For now this is a one-to-one relationship
    //        This most likely should be a list or a map
    O_IXPLogon *lpXPLogon;

    vector<otlkcon_account_details *> *accounts;
    map<wstring,O_ENTRYID*> accountIds;
};

